<?php
namespace app\admin\controller;

use app\common\model\index\NavModel;
use think\admin\Controller;
use think\admin\extend\DataExtend;
use think\admin\helper\QueryHelper;
use think\facade\Validate;

/**
 * 实战链接设置
 * @package app\admin\controller
 * @author Lihongqi
 * @DateTime 2024-09-11 13:58:44
 */
class Set extends Controller
{

    /**
     * 实战链接设置
     * @auth true
     * @menu true
     * @author Lihongqi
     * @DateTime 2024-09-11 14:56:28
     * @return void
     */
    public function index()
    {
        $this->type = $this->request->get('type', 'shop');

        $path = public_path().'other.txt';
        $file = file_get_contents($path);
        $data = json_decode($file, true);

        if ($this->request->isPost()) {

            $content = $this->request->post('content');
            $type    = $this->request->post('type');

            $data[$type] = $content;
            $file = json_encode($data);

            file_put_contents($path, $file);

            $this->success('成功');
        }

        $this->content = $data[$this->type] ?? '';
        $this->fetch();
    }


}